//
//  CNEmptyShopCarView.m
//  BeeQuick_19
//
//  Created by w on 16/9/23.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNEmptyShopCarView.h"
#import "CNTabBarController.h"
#import "UIView+CNViewController.h"

@implementation CNEmptyShopCarView
- (instancetype)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        UIImageView *imageView = [[UIImageView alloc]init];
        //设置图片
        imageView.image = [UIImage imageNamed:@"v2_shop_empty"];
        imageView.contentMode = UIViewContentModeCenter;
        [self addSubview:imageView];
        //lable
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text = @"亲,购物车空空的耶~赶紧的去挑挑好吃的吧";
        titleLable.font = [UIFont systemFontOfSize:16];
        titleLable.textAlignment = NSTextAlignmentCenter;
        titleLable.textColor = [UIColor  colorWithRed:150/255.0 green:150/255.0 blue:150/255.0 alpha:1.0];
        [self addSubview:titleLable];
        //逛逛btn
        UIButton *button = [[UIButton alloc]init];
        [button setBackgroundImage:[UIImage imageNamed:@"btn.png"] forState:UIControlStateNormal];
        [button setTitle:@"去逛逛" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor colorWithRed:100/255.0 green:100/255.0  blue:100/255.0  alpha:1.0] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];

         //布局
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.centerX.equalTo(self);
        }];
        [titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self);
            make.trailing.equalTo(self);
            make.top.equalTo(imageView.mas_bottom);
            make.height.mas_equalTo(50);
        }];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(titleLable.mas_bottom);
            make.centerX.equalTo(self);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo(150);
        }];
        
       
    }
    return self;
}
//按钮的点击事件
- (void)buttonClicked
{
    self.viewController.tabBarController.selectedIndex = 0;
}

@end
